<template>
  <div>
    <el-dialog title="奖金分配" :close-on-click-modal="false" :visible.sync="visible" v-if="visible" :fullscreen="true" @close="callback">
      <el-tabs type="card" v-model="activeName" @tab-click="handleClick" class="tabBox">
        <el-tab-pane label="分配信息" name="first" class="cpTable">
          <div style="height: 73vh;overflow-y: auto; overflow-x: hidden">
            <!-- <jiangjinfpjjfpdjbFpJjxx ref="jiangjinfpjjfpdjbFpJjxx" @refreshDataList="callback">
            </jiangjinfpjjfpdjbFpJjxx> -->
            <fpxx ref="fpxx" @refreshDataList="callback" v-if="activeName=='first'"></fpxx>
          </div>
        </el-tab-pane>
        <el-tab-pane label="奖金来源" name="six" v-if="dataForm.jjLx != bz">
          <jiangjinfpjjfpdjbFpJjly ref="jiangjinfpjjfpdjbFpJjly" @refreshDataList="callback">
          </jiangjinfpjjfpdjbFpJjly>
        </el-tab-pane>
        <el-tab-pane label="部门分配" name="second" v-if="dataForm.jjLx != bz">
          <div class="user__main">
            <jiangjinfpjjfpdjbFpJgxx ref="jiangjinfpjjfpdjbFpJgxx" @refreshDataList="callback">
            </jiangjinfpjjfpdjbFpJgxx>
          </div>
        </el-tab-pane>
        <el-tab-pane label="员工分配" name="third" v-if="dataForm.jjLx != bz">
          <div class="user__main">
            <jiangjinfpjjfpdjbFpGrxx ref="jiangjinfpjjfpdjbFpGrxx" @refreshDataList="callback">
            </jiangjinfpjjfpdjbFpGrxx>
          </div>
        </el-tab-pane>
        <el-tab-pane label="定向分配" name="fourth" v-if="dataForm.jjLx != bz">
          <div class="user__main boxsty">
            <jiangjinfpjjfpdjbFpDxfp ref="jiangjinfpjjfpdjbFpDxfp" @refreshDataList="callback">
            </jiangjinfpjjfpdjbFpDxfp> 
          </div>
        </el-tab-pane>
        <el-tab-pane label="附件管理" name="five" v-if="dataForm.jjLx != bz">
          <jiangjinfpjjfpdjbFileManager ref="jiangjinfpjjfpdjbFileManager"></jiangjinfpjjfpdjbFileManager>
        </el-tab-pane>
      </el-tabs>
      
    </el-dialog>
  </div>
</template>

<script>
import {getObj} from '@/api/jiangjin/jiangjinfpjjfpdjb'
import jiangjinfpjjfpdjbFpGrxx from './jiangjinfpjjfpdjb-fp-grxx'
import jiangjinfpjjfpdjbFpJgxx from './jiangjinfpjjfpdjb-fp-jgxx'
import jiangjinfpjjfpdjbFpJjxx from './jiangjinfpjjfpdjb-fp-jjxx'
import jiangjinfpjjfpdjbFpDxfp from './jiangjinfpjjfpdjb-fp-dxfp'
import jiangjinfpjjfpdjbFpJjly from './jiangjinfpjjfpdjb-fp-jjly'
import jiangjinfpjjfpdjbFileManager from './jiangjinfpjjfpdjb-file-manager'
import fpxx from './view'
import {mapGetters, mapState} from "vuex";

export default {
  data() {
    return {
      bz:2,
      visible: false,
      spvisible: false,
      jjfpId: 0,
      activeName: 'first',
      dataList: [],
      dataForm: {}
    }
  },
  computed: {
    ...mapGetters(['permissions']),
    ...mapState({
      userInfo: (state) => state.user.userInfo,
    }),
  },
  components: {
    jiangjinfpjjfpdjbFpDxfp,
    jiangjinfpjjfpdjbFpGrxx,
    jiangjinfpjjfpdjbFpJgxx,
    jiangjinfpjjfpdjbFpJjxx,
    jiangjinfpjjfpdjbFpJjly,
    jiangjinfpjjfpdjbFileManager,
    fpxx
  },
  methods: {
    init(id) {
      this.visible = true;
      this.jjfpId = id;
      this.activeName = 'first';

      getObj(this.jjfpId).then(response => {
        this.dataForm = response.data.data
      })

      this.getView();
    },
    //奖金概况
    getView() {
      this.$nextTick(() => {
        // this.$refs.fpxx.init(null,
        //   null,
        //   null,
        //   null,
        //   {ywLyid: this.jjfpId},
        //   null,
        //   null,
        //   null)
        this.$refs.fpxx.init(this.jjfpId)
      });
    },
    handleClick(tab, event) {
      if (tab.name == "first") {
        this.getView();
      } else if (tab.name == "second") {
        var params={
          type:"oldJiang",
          id:this.jjfpId
        }
        this.$refs.jiangjinfpjjfpdjbFpJgxx.init(params);
      } else if (tab.name == "third") {
        var params={
          type:"oldJiang",
          id:this.jjfpId
        }
        this.$refs.jiangjinfpjjfpdjbFpGrxx.init(params);
      } else if (tab.name == "fourth") {
        this.$refs.jiangjinfpjjfpdjbFpDxfp.init(this.jjfpId);
      } else if (tab.name == "five") {
        this.$refs.jiangjinfpjjfpdjbFileManager.init(this.jjfpId);
      } else if (tab.name == "six") {
        this.$refs.jiangjinfpjjfpdjbFpJjly.init(this.jjfpId);
      }
    },
    callback() {
      this.$emit('refreshDataList')
    }
  }
}

</script>
